package playn.game.menu.states;

import playn.core.GroupLayer;
import playn.core.Keyboard.Event;
import playn.game.core.Button;
import playn.game.core.Game;
import playn.game.core.State;
import playn.game.menu.Menu;



public class Pause extends State {

	public final static String PAUSE_BUTTON_ID="Pause";
	public final static String RESUME_BUTTON_ID="Resume";
	
	public Pause(GroupLayer layer){
		super(layer);
		name="PAUSE";
		map=Game.maps.get("Pause.tmx");
	}

	
	@Override
	public void onKeyDown(Event event){
	    switch (event.key()) {
	      case P:{
				Game.menu.switchTo(Menu.ACTION);
				Game.action=true;
				break;
	      }
	    }
	}
	
	
	@Override
	public void onPress(Button button){
		if(button.id().equalsIgnoreCase(Pause.RESUME_BUTTON_ID)){
			Game.menu.switchTo(Menu.ACTION);
			Game.action=true;
		} else  if(button.id().equalsIgnoreCase(Levels.LEVELS_BUTTON_ID)){
			
			transition.addOut(Game.level.layer);
			
			Game.menu.switchTo(Menu.LEVELS);
		}
		else {
			super.onPress(button);
		}
	}
}
